<template>
  <div class="right-content-main">
    <div class="header">
      <div class="title"  v-if="pagingData.type">{{resultInfo.name}}</div>
      <div class="current-box ">
        <span class="current-text">当前位置</span>
        <span class="line"></span>
        <span class="">首页</span>
        <span class="line"></span>
        <span class="">技术成果</span>
        <span class="line"></span>
        <span class="">{{resultInfo.name}}</span>
      </div>
    </div>
    <div class="content">
      <ul class="info-list">
        <li class="mask-box" @click="handleDetails(item)" v-for="item in dataList" :key="item.id">
          <div class="info-content">
            <p class="line-2 title">{{ item.tecname }}</p>
            <p class="time df-sc gap-10">
              <span>{{ item.year }}</span>
              <span class="flex-1 line-1">{{item.author}}</span>
            </p>
            <p class="introduce line-2">{{ item.unit }}</p>
          </div>
        </li>
      </ul>
      <div class="df-cc">
        <el-pagination v-if="pagingData.total" background layout="prev, pager, next" :total="pagingData.total"
                       v-model:current-page="pagingData.pageNum" :page-size="pagingData.pageSize"
                       @current-change="loadPageData()"></el-pagination>
      </div>
    </div>
  </div>
</template>

<script setup>
import {homeApi} from "@/api";
import { useRouter} from "vue-router";

const pagingData = reactive({
  pageNum: 1,
  pageSize:12,
  type: '',
  total: 0
})
const resultInfo = ref({})
const dataList = ref([])

async function loadPageData(data) {
  if (data) {
    resultInfo.value = data
    pagingData.type=data.code
  }
  const res = await homeApi.technologyViewInfoListPage.get(pagingData)
  dataList.value = res.list
  pagingData.total = res.total||0

}

const router = useRouter()

function handleDetails(item) {
  router.push({
    path: '/details',
    query: {
      type: 3,
      id: item.id
    }
  })
}

defineExpose({loadPageData})
</script>

<style scoped lang="scss">
.right-content-main {
  flex: 1;
  min-height: 700px;
  height: 100%;
  background: #FFFFFF;

  .header {
    height: 80px;
    margin: 0 24px;
    border-bottom: 1px solid #ccc;
    display: flex;
    justify-content: space-between;

    .current-box {
      display: flex;
      align-items: center;
      color: #333333;
      font-size: 16px;

      .line {
        width: 20px;
        border-bottom: 1px solid #333;
        margin: 0 5px;
      }

      .current-text {
        color: #999;
      }

      .base-text {
        color: $base-color;
      }
    }

    .title {
      position: relative;
      height: 100%;
      padding-top: 16px;
      font-size: 26px;
      font-weight: bold;
      color: $base-color;

      &::after {
        content: '';
        width: 100%;
        border-bottom: 2px solid $base-color;
        position: absolute;
        left: 0;
        bottom: 0;
      }
    }
  }

  .content {
    margin: 24px;
    .info-list {
      display: flex;
      flex-wrap: wrap;
      gap: 16px;
      width: 100%;
      margin-bottom: 16px;
      li {
        width: calc(100% / 3 - 12px);
        padding: 12px 8px 6px;
        background: #F5F5F5;
        color: #333333;
        --bg-color: #60B9AA;
        &:nth-child(1){
          --bg-color: #015293;
        }
        &:nth-child(3){
          --bg-color: #015293;
        }
        &:nth-child(4){
          --bg-color: #015293;
        }
        &:nth-child(6){
          --bg-color: #015293;
        }
        &:nth-child(7){
          --bg-color: #015293;
        }
        &:nth-child(9){
          --bg-color: #015293;
        }
        &:nth-child(10){
          --bg-color: #015293;
        }
        &:nth-child(12){
          --bg-color: #015293;
        }

        &:hover {
          color: #FFFFFF;
        }
        .info-content {
          position: relative;
          z-index: 2;
        }



        .title {
          font-size: 18px;
          font-weight: bold;
          height: 46px;
        }

        .time {
          font-size: 18px;
          margin: 10px 0;
        }

        .introduce {
          color: #999999;
          font-size: 16px;
        }
      }
    }
  }
}
</style>
